<script setup lang="ts">
import PopBoxMask from './components/PopBoxMask.vue';
import PopBoxContent from './components/PopBoxContent.vue';
import PopBoxBar from './components/PopBoxBar.vue';
import PopBoxMain from './components/PopBoxMain.vue';
import PopBoxDragBar from './components/PopBoxDragBar.vue';
import { onUnmounted } from 'vue';

const props: any = defineProps<{
    ujt: any;
    id?: string;
    full?: number;
    maskstyle?: any;
    popstyle?: any;
}>();
const { $global } = props.ujt;
// 初始化pop数据
if (!props.id) {
    props.id = 'popdefault';
}
if (!$global.pop[props.id]) {
    $global.pop[props.id] = {};
}

// 转化入参
if (props.full && !$global.pop[props.id].full) {
    $global.pop[props.id].full = props.full;
}
if (props.maskstyle && !$global.pop[props.id].maskstyle) {
    $global.pop[props.id].maskstyle = props.maskstyle;
}
if (props.popstyle && !$global.pop[props.id].popstyle) {
    $global.pop[props.id].popstyle = props.popstyle;
}

onUnmounted(() => {
    $global.pop[props.id] = {};
});
</script>

<template>
    <PopBoxMask :ujt="ujt" :id="id" v-if="$global.pop[props.id].stat">
        <KeepAlive>
            <PopBoxMain :ujt="ujt" :id="id">
                <PopBoxDragBar :ujt="ujt" :id="id">
                    <PopBoxBar :ujt="ujt" :id="id"></PopBoxBar>
                </PopBoxDragBar>
                <PopBoxContent :ujt="ujt" :id="id"><slot></slot></PopBoxContent>
            </PopBoxMain>
        </KeepAlive>
    </PopBoxMask>
</template>

<style scoped lang="scss"></style>
